const {resolve} = require("path");
const {type} = require("os");
const openBrowser = type() === "Windows_NT" ? "chrome"
	: type() === "Darwin" ? "Google Chrome" : "google-chrome"
;
const htmlWebpackPlugin = require("html-webpack-plugin")
module.exports = {
	entry: "./index.js",
	output: {
		clean: true,
		filename: "build.js",
		path: resolve(__dirname, "dist"),
	},
	module: {
		rules: [
			{
				test: /\.js$/,
				exclude: /node_modules/,
				use: {
					loader: "babel-loader",
					options: {
						presets: [
							[
								"@babel/preset-env"
							]
						]
					}
				}
			}
		]
	},
	plugins: [
		new htmlWebpackPlugin({
			title: "promise",
			template: "index.html",
			minify: {
				removeAttributeQuotes: true,
				removeComments: true,
				collapseWhitespace: true
			}
		})
	],
	mode: "development",
	devServer: {
		port: process.env.npm_package_config_port,
		compress: true,
		hot: true,
		open: {
			app: {
				name: openBrowser
			}
		}
	}
}
